Collected in river Umeälven (and tributary Vindelälven) and Dalälven
Total fecundity available (stripped + dissected). I.e. All eggs are counted!
Also trout data that is filtered out.
Sweden 2 - Swedish west coast
Collected in rearing station in river Göta älv
All fin-clipped individuals.
Only stripped (from what V.T. knows, methods description lacking atm)
Not total fecundity as in Sweden 1
Finland 1
Described in the report “HYDROACOUSTIC ASSESSMENT OF SALMON IN THE RIVER TORNIONJOKI - FINAL REPORT, EU STUDY PROJECT 96-069”
Total fecundity available (stripped + dissected). I.e. an estimation of all eggs!
From river Tornionjoki
Both reared (finclipped) and wild individuals (adipose fin intact) but the majority are wild.
Finland 2
From river Tornionjoki and Simojoki
wild, reared and NA mix of individuals
France
Described in the Samarch report “Changes in sex ratio and fecundity of salmonids” (M. Nevoux et al. 2020, Deliverable D3.3.1)
Methods for assessing fecundity is stripping and a subset of the volume (or weight) of eggs were counted, then the total fecundity was extrapolated based on the total volume (weight) of the stripped eggs (pers. com M. Nevoux)
From 13 rivers in three regions
Origin should mainly be wild (pers. com. M. Nevoux)
The data is filtered in Section 4 when combining data.
2. Spatial aggregations - Baltic Assessment and Atlantic Stock units and Regions
To add spatial information, site name in the data is matched (dplyr::left_join():ed) with site name in the tables created below (SweFin.rivers and French.rivers).
The spatial information added is:
Coordinates (WGS84 DD). French coordinates either provided by Hilaire Drouineau or added manually by V.T., they are at the river mouth (entering the sea or from a tributary) or for the Baie Mont St Michelle in the center of the bay. These are not catch places. For many tributary rivers, the main river mouth is used and for those rivers,the names are changed in 3a when combining data. Swedish coordinates eother existing in the data or added manually (river mouth, not catch place).
Stock unit (for WGNAS stock unit Sweden and France),
Assessment unit (for WGBAST),
Region and genetic region from French regions from Perrier et al. 2011 (doi: 10.1111/j.1365-294X.2011.05266.x), and provided by M. Nevoux, existing in the french fecundity data or added manually by V.T with input from M. Nevoux. Swedish regions are defined as Baltic Sea and Swedish west coast and Finnish is Baltic Sea.
Show code
# Assessment units of the index rivers in Sweden and Finland. AU.rivers =bind_cols(site =c("Tornionjoki","Simojoki","Kalixälven","Råneälven","Piteälven","Åbyälven","Byskeälven","Rickleån","Sävarån","Vindelälven","Öreälven","Lögdeälven","Ljungan","Mörrumsån","Emån", "Kågeälven","Testeboån", "Umeälven", "Dalälven", "Luleälven","Muonionjoki"),asses.unit =c(1,1,1,1,2,2,2,2,2,2,2,2,3,4,4,2,3,2,3,2,1), stock.origin ="wild") %>%bind_rows(bind_cols(site =c("Torneälven_hatchery","Luleälven_(RG_with_Pite)","Iijoki","Oulujoki","Skellefteälven","Umeälven_(RG_with_Vindel)","Ångermanälven","Indalsälven_(RG_with_Ljungan)","Ljusnan","Dalälven_(RG_with_Testeboån)", "Torneälven","Gideälven"), asses.unit =c(1,2,1,1,2,2,3,3,3,3,1,2), stock.origin ="reared")) # And the Swedish rivers entering the the Western sea, i.e. WGNAS stock unit "Sweden".SU.rivers =bind_cols(site =c("Ätran","Örekilsälven","Göta älv","Lagan","Västerhavet (hela) ICES SD 20-21","Genevadsån","Fylleån","Stensån"),stock.unit ="Sweden", stock.origin =NA)# Add AU and SU to lat lons from Swedish sötebasenSweFin.rivers <- swe.sallaa %>%drop_na(length) %>%distinct(site, WGS84_N_Vatten, WGS84_E_Vatten) %>%rename(lat = WGS84_N_Vatten,lon = WGS84_E_Vatten) %>%mutate(lat =case_when(site =="Östersjön (hela) ICES SD 22-32"~58.475309,.default = lat),lon =case_when(site =="Östersjön (hela) ICES SD 22-32"~19.780140,.default = lon)) %>%bind_rows(data.frame(site =c("Tornionjoki", "Simojoki", "Muonionjoki")) %>%mutate(lat =case_when(site %in%c("Tornionjoki", "Muonionjoki") ~65.879905, site =="Simojoki"~65.625639, site =="Östersjön (hela) ICES SD 22-32"~58.475309, site =="Gideälven"~63.327482,.default =NA),lon =case_when(site %in%c("Tornionjoki", "Simojoki", "Muonionjoki") ~24.136424, site =="Simojoki"~25.052169, site =="Östersjön (hela) ICES SD 22-32"~19.780140, site =="Gideälven"~19.140244,.default =NA))) %>%left_join(AU.rivers) %>%left_join(SU.rivers) %>%mutate(region =if_else(stock.unit =="Sweden", "Swedish.westcoast", "Baltic.sea", missing ="Baltic.sea" )) # French rivers by region and sub-regions from Marie Nevouxfra.rivers <-read_csv(file ="/Users/vitl0001/Documents/Projects/DIASPARA/riviere_region_France.csv") %>%mutate(site =str_to_title(river),stock.unit ="France")# French site abbreviations for regional genotypic aggregations from Perrier et al. 2011fra.rivabb <-read_delim(file ="/Users/vitl0001/Documents/Projects/DIASPARA/french_genotypes_Perrier.txt", delim ="\t") %>%rename(site = River) %>%mutate(site.abb =str_to_upper(str_sub(site,start =1, end =3)),site.abb =case_when(site =="NIVE"~"NIE", site =="NIVELLE"~"NIL",.default = site.abb),site =str_to_title(site)) %>%mutate(region.gen =case_when(site.abb %in%c("COU","TRI","DOU","LEG","STE","AUL","GOY","ELO","ELL","PEN","ODE","AVE","JET","SCO","BLA") ~"Brittany", site.abb %in%c("ORN", "VIR","SEI","SAI","SIE","SEL","SEE") ~"Lower-Normandy", site.abb %in%c("NIL","NIE","GAV") ~"Adour", site.abb %in%c("GAR","DOR","ALL") ~"Allier-Gironde", site.abb %in%c("TOU","VAL","AUT","CAN","BRE","ARQ") ~"Upper-Normandy",.default =NA))# French site coordinates from Hilaire Drouineaufra.rivers.sf <-read_sf("/Users/vitl0001/Documents/Projects/DIASPARA/salmon_frarivers", stringsAsFactors =FALSE)# Combine all French site infofra.rivers2 <- fra.rivers %>%full_join(fra.rivabb) %>%bind_rows(# adding missing rivers from fra.sallaatibble(site =c("Isole", "Etel", "Quillec", "Horn", "St Laurent"), region.gen ="Brittany", stock.unit ="France"),tibble(site =c("Baie Du Mont Saint Michel","Thar"), region.gen ="Lower-Normandy", stock.unit ="France"),tibble(site =c("Loire"), region.gen ="Allier-Gironde", stock.unit ="France"),tibble(site =c("Durdent"), region.gen ="Upper-Normandy", stock.unit ="France")) %>%left_join(st_coordinates(fra.rivers.sf) %>%as.data.frame() %>%rename(lon = X,lat = Y) %>%bind_cols(st_set_geometry(fra.rivers.sf, NULL)) %>%rename(site ="river")) %>%# assign region.gen to those missingmutate(region.gen =case_when(site =="Oir"~"Lower-Normandy", subregion =="Adour"&is.na(site.abb) ~"Adour", subregion =="Gironde"&is.na(site.abb) ~"Allier-Gironde", region =="Bretagne"&is.na(site.abb) ~"Brittany",.default = region.gen)) %>%# remove those " + affl" which are tributaries, Gave Mauleon (Le Saison) which is Gave Mauleon, "Gave'oloron duplictae and See Selune which are exists individually.filter(!site %in%c("See Selune","Odet + Affl","Elle + Affl","Gave Mauleon (Le Saison)", "Gave D'oloron") ) %>%# add lat and lons where missing.mutate(lat =case_when(site =="Baie Du Mont Saint Michel"~48.655943, site =="Valmont"~49.761966, site =="Seine"~49.435474, site =="Isole"~47.874431, site =="Loire"~47.281585, site =="Finistere"~48.306467, site =="Etel"~47.656579, site =="Quillec"~48.685033, site =="Etel"~47.656579, site =="Thar"~48.800103, site =="Loire"~47.281585, site =="Horn"~48.688119, site =="Durdent"~48.687806, site =="Canche"~50.527333, site =="Couesnon"~48.625250, site =="St Laurent"~47.903795,.default = lat),lon =case_when(site =="Baie Du Mont Saint Michel"~-1.656370, site =="Valmont"~0.377126, site =="Seine"~0.285060, site =="Isole"~-3.546855, site =="Loire"~-2.152414, site =="Finistere"~-4.080223, site =="Etel"~-3.209520, site =="Quillec"~-4.069429, site =="Thar"~-1.568264, site =="Loire"~-2.152414, site =="Horn"~-4.058391, site =="Durdent"~0.608712, site =="Canche"~1.614964, site =="Couesnon"~-1.511461, site =="St Laurent"~-3.945979,.default = lon)) %>%# remove non-necessary infoselect(-subregion,-region,-id,-site.abb)
3. Length at age
3a. Filter, clean and combine data
Keeping only adult individuals (removing NA and 0 sea age individuals).
Remove NA values in length and age.
Remove individuals from Swedish lakes
Remove three mark-recaptured individuals in Swedish data
Remove an obvious outlier in the French data
Correct an obvious outlier in the French data
Calculate total length (\(L_t\)) from fork length (\(L_f\)) where needed in the French data based on the model: \(exp(0.2892351)*L_f^{0.9623479}\) (see below).
The french data has two sources of sex identification (observed in the field vs genetic). I use Genetic sex where available and complete these data with field observations. M. Nevoux considers field observations correct only from (mid) August. From the data where both genetic and field method are available, 14% are incorrect. Keep this in mind if using this info. The sex in Finnish (and likely in Swedish data) is determined visually when gutting the fish and far from all are determined (many NAs).
The kept variables are: length, site, country, origin, year, age_ad, sex. Spatial varaibles are added to the data from the tables created in 2.
Show code
# 14 % of the sex determinations in th field are wrong.fra.sallaa %>%drop_na(`Genetic sex`, `Sex observed in the field`) %>%rename(gs =`Genetic sex`,fs =`Sex observed in the field`) %>%filter(gs != fs) %>%summarise(perc.incorr =100*n()/nrow(fra.sallaa %>%drop_na(`Genetic sex`, `Sex observed in the field`)))
drop_na: removed 68,383 rows (95%), 3,738 rows remaining
rename: renamed 2 variables (fs, gs)
filter: removed 3,031 rows (81%), 707 rows remaining
drop_na: removed 68,383 rows (95%), 3,738 rows remaining
summarise: now one row and one column, ungrouped
# A tibble: 1 × 1
perc.incorr
<dbl>
1 18.9
Show code
# Model to convert fork length in the French data to total length. V.T. models this relationship using a log-linear model (Lt = a*Lf^b) to estimate a and b. Lt ~ Lf is almost linear but a log(Lt)~log(Lf) relationship makes for a seemingly better fit.fra.sallaa %>%filter(total_length >100) %>%drop_na(total_length, fork_length) %>%lm(log(total_length) ~log(fork_length), data = .) %>%tidy() %>%pull(estimate)
#looks good:fra.sallaa %>%filter(total_length >100) %>%# an obvious outlier where Lf >> Ltdrop_na(total_length, fork_length) %>%ggplot(aes(fork_length, total_length)) +geom_point() +geom_line(aes(x = fork_length, y =exp(0.2892351)*fork_length^0.9623479), col ="red") +labs(title ="fork to total length fit length at age")
# There are three mark-recaptured individuals in Swedish db Sötebasaen when NA lengths and ages are removed. As they are so few: Id them and remove the first age-length measurement and keep later one (when they are bigger). They are all recaptured within the same year.dup.markrec <- swe.sallaa %>%# remove NAsdrop_na(length, age.sea, MärkeNr) %>%# find the mark-recaptured ones by counting rows by tag number mutate(n =n(), .by = MärkeNr) %>%# filter the mark-recaps and those with info that is not tags ("finclipped")filter(n >1&!MärkeNr =="Fenklippt") %>%# id the mark (shorter) instanceslice_min(length, by = MärkeNr)
drop_na: removed 105,549 rows (>99%), 300 rows remaining
mutate: new variable 'n' (integer) with 3 unique values and 0% NA
filter: removed 294 rows (98%), 6 rows remaining
slice_min: removed 3 rows (50%), 3 rows remaining
Show code
# Combine the dataall.sallaa <- swe.sallaa %>%# remove the mark-recapsanti_join(dup.markrec) %>%# remove the lakes in the datafilter(!site %in%c("Vättern", "Vänern")) %>%drop_na(length) %>% dplyr::select("country", "year", "site", "origin", "length", "weight", "AU", "age.sea", "age.sm", "sex") %>%bind_rows(fin.sallaa %>%# remove individuals without length or sea agedrop_na(length) %>% dplyr::select("country", "year", "site", "origin", "length", "weight", "age.sea", "age.sm", "sex")) %>%bind_rows(fin.sallaa2 %>%# remove individuals without length or sea agedrop_na(length) %>% dplyr::select("country", "year", "site", "origin", "length", "weight", "age.sea", "age.sm","sex")) %>%left_join(SweFin.rivers, by ="site") %>%# prefer the existing AU before the new one.mutate(asses.unit =if_else(is.na(AU), asses.unit, AU)) %>% dplyr::select(!AU) %>%bind_rows(fra.sallaa %>%rename(gen.sex =`Genetic sex`,field.sex =`Sex observed in the field`) %>%mutate(# remove french accents and hyphenssite = stringi::stri_trans_general(site, "Latin-ASCII"),site =str_replace_all(site,"-"," "),# changing tributaries to main site site =case_when(site %in%c("Varenne","Bethune") ~"Arques", site %in%c("Inam") ~"Elle", site %in%c("Austreberthe") ~"Seine", site %in%c("Arroux", "Allier") ~"Loire", site %in%c("Jet","Steir") ~"Odet",.default = site),# Using observed sex in the field when genetic is missing to complete infosex =str_to_lower(if_else(is.na(gen.sex), field.sex, gen.sex)), # correct a "1" valued entry to NAsex =if_else(sex %in%c("f","m"), sex, NA),# calculate total from fork length and correct TL outlier: 51 mm and 2 yolength =if_else(is.na(total_length) | total_length ==51, exp(0.2892351)*fork_length^0.9623479, total_length), # Correct one ind. at 7900 mm and assume it is 790 mmlength =ifelse(length >2000, length/10, length), ) %>%drop_na(length) %>% dplyr::select("country", "year", "site", "origin", "length", "age.sea", "age.sm", "sex") %>%mutate(weight =NA) %>%left_join(fra.rivers2))
Joining with `by = join_by(InsamlingID, Serie, InsamlMetod, AnstrTyp,
IndividID, site, RT90_X_Vatten, RT90_Y_Vatten, S99TM_N_Vatten, S99TM_E_Vatten,
WGS84_N_Vatten, WGS84_E_Vatten, Plats, RT90_X_Plats, RT90_Y_Plats,
S99TM_N_Plats, S99TM_E_Plats, WGS84_N_Plats, WGS84_E_Plats, Subdiv, AU, Syfte,
year, FångstDatum, Art, Åldersprov, IndividNr, length, weight, Behandling, Kön,
stage, Genprov, Märkning, MärkeNr, Märkning2, Märke2Nr, origin, age.sm,
age.sea, Pluszon, AntalLek, ÅlderLek1, ÅlderLek2, ÅlderLek3, Tydlighet,
AnmÅlder, country, sex)`
anti_join: added no columns
> rows only in x 105,846
> rows only in dup.markrec ( 0)
> matched rows ( 3)
> =========
> rows total 105,846
filter: removed 36,152 rows (34%), 69,694 rows remaining
drop_na: removed 3,682 rows (5%), 66,012 rows remaining
drop_na: removed 254 rows (18%), 1,125 rows remaining
drop_na: removed 771 rows (5%), 13,908 rows remaining
left_join: added 6 columns (lat, lon, asses.unit, stock.origin, stock.unit, …)
> rows only in x 0
> rows only in SweFin.rivers ( 4)
> matched rows 81,051 (includes duplicates)
> ========
> rows total 81,051
mutate: changed 1,215 values (1%) of 'asses.unit' (1,140 fewer NAs)
rename: renamed 2 variables (field.sex, gen.sex)
mutate: changed 14,902 values (21%) of 'site' (0 new NAs)
new variable 'sex' (character) with 3 unique values and 42% NA
new variable 'length' (double) with 741 unique values and 0% NA
drop_na: no rows removed
mutate: new variable 'weight' (logical) with one unique value and 100% NA
Joining with `by = join_by(site)`
left_join: added 5 columns (river, stock.unit, region.gen, lon, lat)
> rows only in x 0
> rows only in fra.rivers2 ( 12)
> matched rows 79,187 (includes duplicates)
> ========
> rows total 79,187
Show code
str(all.sallaa)
tibble [160,238 × 17] (S3: tbl_df/tbl/data.frame)
$ country : chr [1:160238] "SWE" "SWE" "SWE" "SWE" ...
$ year : num [1:160238] 2015 2015 2015 2015 2015 ...
$ site : chr [1:160238] "Östersjön (hela) ICES SD 22-32" "Östersjön (hela) ICES SD 22-32" "Östersjön (hela) ICES SD 22-32" "Östersjön (hela) ICES SD 22-32" ...
$ origin : chr [1:160238] "wild" "wild" "wild" "reared" ...
$ length : num [1:160238] 990 840 860 880 860 1000 860 820 830 840 ...
$ weight : num [1:160238] 930000 540000 590000 440000 500000 830000 550000 510000 530000 550000 ...
$ age.sea : num [1:160238] 4 2 2 3 3 3 2 2 3 2 ...
$ age.sm : num [1:160238] 3 3 2 NA 4 3 3 3 2 3 ...
$ sex : chr [1:160238] "m" "f" "f" "f" ...
$ lat : num [1:160238] 58.5 58.5 58.5 58.5 58.5 ...
$ lon : num [1:160238] 19.8 19.8 19.8 19.8 19.8 ...
$ asses.unit : num [1:160238] NA NA NA NA NA NA NA NA NA NA ...
$ stock.origin: chr [1:160238] NA NA NA NA ...
$ stock.unit : chr [1:160238] NA NA NA NA ...
$ region : chr [1:160238] "Baltic.sea" "Baltic.sea" "Baltic.sea" "Baltic.sea" ...
$ river : chr [1:160238] NA NA NA NA ...
$ region.gen : chr [1:160238] NA NA NA NA ...
mutate: new variable 'spat.unit' (character) with 11 unique values and 0% NA
3c. Correct age types Map and summary of length at age
Show code
all.sallaa2 <- all.sallaa %>%rowwise() %>%# rowwise needed for non vectorised function like sum# create life stage and total age columnsmutate(age.type =case_when(is.na(age.sea) &is.na(age.sm) ~NA, age.sea ==0|is.na(age.sea) ~"smolt.only", age.sea >0& age.sm >0~"both", age.sm ==0|is.na(age.sm) ~"sea.only",.default =NA),age.tot =sum(age.sea,age.sm, na.rm =TRUE),# sum(NA,NA, na.rm = TRUE) is 0 but they should be NAage.tot =if_else(age.tot ==0, NA, age.tot)) %>%ungroup()
mutate: new variable 'age.type' (character) with 4 unique values and 21% NA
new variable 'age.tot' (double) with 13 unique values and 21% NA
ungroup: no grouping variables remain
Show code
# Fix ages that are not correctly classified (see 2-2_Salmon_data_v2)all.sallaa3 <- all.sallaa2 %>%# set sea age = smolt age mutate(age.sea =case_when(age.type =="smolt.only"& length >=290~ age.sm,.default = age.sea),# set smolt age = 0, age.sm =case_when(age.type =="smolt.only"& length >=290&!is.na(age.sm) ~0,.default = age.sm),# reclassify their age typesage.type =case_when(age.type =="smolt.only"& length >=290~"sea.only",.default = age.type))
mutate: changed 153 values (<1%) of 'age.sea' (98 fewer NAs)
changed 127 values (<1%) of 'age.sm' (0 new NAs)
changed 154 values (<1%) of 'age.type' (0 new NAs)
Show code
# Check. # Id sites with smoltssws <- all.sallaa3 %>%filter(age.type =="smolt.only") %>%distinct(site) %>%pull(site)
Warning: Removed 67 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 59 rows containing missing values or values outside the scale range
(`geom_point()`).
3d. Correct weights
There is no weight measurements in the French length at age data.
Show code
# Swedish weights are in milligrams*10. So divide by 100 to get grams.all.sallaa3 %>%drop_na(age.tot) %>%# two na-aged swedish fish with wrong lw-relationships removedggplot() +geom_point(aes(length, weight, color = country)) +facet_wrap(~country, scales ="free")
Warning: Removed 81583 rows containing missing values or values outside the scale range
(`geom_point()`).
3d. Map and summary of length at age
Show code
# length at age by a suitable spatial aggregation (spat.unit) is defined as French regions, Swedish west coast and Baltic assessment units. This results in 10 spatial units (plus an NA group which will disappear when the French region information is complete) which should represent genetic and ecological units. There are observations without assessment units in the Baltic as the only spatial information we have is that they are from the Baltic as a whole. all.sallaa4 %>%ggplot(aes(age.sea, length, color = spat.unit)) +geom_point() +facet_wrap( ~spat.unit) +expand_limits(x =0)
Warning: Removed 41591 rows containing missing values or values outside the scale range
(`geom_point()`).
drop_na: no rows removed
mutate: new variable 'n.years' (integer) with 32 unique values and 0% NA
mutate: new variable 'count.year' (character) with 2 unique values and 0% NA
# A tibble: 29 × 20
country year site origin length weight age.sea age.sm sex lat lon
<chr> <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <chr> <dbl> <dbl>
1 FRA 1989 Etel <NA> 740 NA 2 2 f 47.7 -3.21
2 FRA 2003 Scorff <NA> 633. NA 2 1 f 47.7 -3.35
3 FRA 1987 Blavet <NA> 770 NA 2 2 <NA> 47.7 -3.32
4 FRA 1987 Aven <NA> 715 NA 2 1 <NA> 47.8 -3.74
5 FRA 1987 Odet <NA> 750 NA 2 1 <NA> 47.9 -4.12
6 FRA 1987 Odet <NA> 750 NA 2 1 <NA> 47.9 -4.12
7 FRA 1988 Isole <NA> 740 NA 2 1 f 47.9 -3.55
8 FRA 1988 St Laure… <NA> 590 NA 1 1 m 47.9 -3.95
9 FRA 1987 Goyen <NA> 800 NA 2 1 <NA> 48.0 -4.54
10 FRA 1987 Aulne <NA> 780 NA 2 1 <NA> 48.3 -4.28
# ℹ 19 more rows
# ℹ 9 more variables: asses.unit <dbl>, stock.origin <chr>, stock.unit <chr>,
# region <chr>, river <chr>, region.gen <chr>, spat.unit <chr>,
# age.type <chr>, age.tot <dbl>
Show code
# ind counts by site FRANCEall.sallaa4 %>%mutate(river1 =paste0(country,":",site)) %>%summarise(count =n(), .by =c(year, country, river1)) %>%mutate(count.ind =as.factor(ifelse(count >50, ">50",ifelse(count >30& count <=50, ">30",ifelse(count >10& count <=30, ">10","1 - 10")))),count.ind =fct_reorder(count.ind, count)) %>%filter(country =="FRA") %>%ggplot(aes(year, river1, fill = count.ind, group = country)) +geom_tile(color ="gray30") +scale_fill_viridis_d() +theme_light() +theme(axis_text=element_text(size=5))
mutate: new variable 'river1' (character) with 107 unique values and 0% NA
summarise: now 1,592 rows and 4 columns, ungrouped
mutate: new variable 'count.ind' (factor) with 4 unique values and 0% NA
filter: removed 310 rows (19%), 1,282 rows remaining
Warning in plot_theme(plot): The `axis_text` theme element is not defined in
the element hierarchy.
Show code
# ind counts by site FINLAND and SWEDENall.sallaa4 %>%mutate(river1 =paste0(country,":",site)) %>%summarise(count =n(), .by =c(year, country, river1)) %>%mutate(count.ind =as.factor(ifelse(count >50, ">50",ifelse(count >30& count <=50, ">30",ifelse(count >10& count <=30, ">10","1 - 10")))),count.ind =fct_reorder(count.ind, count)) %>%filter(!country =="FRA") %>%ggplot(aes(year, river1, fill = count.ind, group = country)) +geom_tile(color ="gray30") +scale_fill_viridis_d() +theme_light()
mutate: new variable 'river1' (character) with 107 unique values and 0% NA
summarise: now 1,592 rows and 4 columns, ungrouped
mutate: new variable 'count.ind' (factor) with 4 unique values and 0% NA
filter: removed 1,282 rows (81%), 310 rows remaining
Warning: Removed 1 row containing missing values or values outside the scale range
(`geom_tile()`).
By suggested spatial aggregation:
Show code
# ind counts by a suggested spatial aggregationall.sallaa4 %>%summarise(count =n(), .by =c(year, spat.unit)) %>%mutate(Ind.count =as.factor(ifelse(count >50, ">50",ifelse(count >30& count <=50, ">30",ifelse(count >10& count <=30, ">10","1 - 10")))),Ind.count =fct_reorder(Ind.count, count)) %>%ggplot(aes(year, spat.unit, fill = Ind.count)) +geom_tile(color ="gray30") +scale_fill_viridis_d() +labs(y ="") +theme_light()
summarise: now 390 rows and 3 columns, ungrouped
mutate: new variable 'Ind.count' (factor) with 4 unique values and 0% NA
Warning: Removed 1 row containing missing values or values outside the scale range
(`geom_tile()`).
Show code
ggsave("laa_temp.png", scale =0.8)
Saving 5.6 x 4 in image
Warning: Removed 1 row containing missing values or values outside the scale range
(`geom_tile()`).
Show code
# sex information by suggested spatial regionall.sallaa4 %>%summarise(ind.count =n(), .by =c(spat.unit, sex)) %>%ggplot(aes(ind.count, sex, fill = spat.unit)) +geom_bar(stat="identity", position ="stack") +scale_fill_viridis_d()
summarise: now 33 rows and 3 columns, ungrouped
Show code
# Number of individuals by suggested spatial regionall.sallaa4 %>%summarise(ind.count =n(), .by =c(year, spat.unit)) %>%ggplot(aes(ind.count, spat.unit)) +geom_bar(stat="identity", position ="stack", fill ="#440154FF") +geom_text(aes(label = ind.count), nudge_x =2400)
summarise: now 390 rows and 3 columns, ungrouped
4. Fecundity at length
4a. Filter, clean and combine data
Remove NA values in length and fecundity (n.eggs)
Correct an obvious outlier in the Finnish data 1
Calculate total length (\(L_t\))from fork length (\(L_f\)) where needed in the French data based on the model: \(exp(0.05704206)*L_f^{0.99670332}\) (see below).
The kept variables are: length, site, country, origin, year, n.eggs. Spatial variables are added to the data from the tables created in 2.
Show code
# Model to convert French fork lengths in the fecundity data to total lengthsfra.salfec %>%drop_na(length.t, length.f) %>%lm(log(length.t) ~log(length.f), data = .) %>%tidy() %>%pull(estimate)
fra.salfec %>%drop_na(length.t, length.f) %>%ggplot(aes(length.f, length.t)) +geom_point() +geom_line(aes(x = length.f, y =exp(0.05704206)*length.f^0.99670332), col ="red") +labs(title ="fork to total length fit fecundity")